#ifndef SESSIONPRESENCEMANAGER_H
#define SESSIONPRESENCEMANAGER_H

#include <map>

#include "ISerializable.h"
#include "SessionPresence.h"

class SessionPresenceManager : public ISerializable
{
public:
  typedef std::map<std::string, SessionPresence> SessionPresenceMap;
  typedef std::pair<std::string, SessionPresence> SessionPresencePair;

  SessionPresenceManager()
  {    
  }

  virtual ~SessionPresenceManager()
  {
  }

  const SessionPresenceMap& presenceRecords() const { return m_sessionPresences; }
  const SessionPresence *sessionPresenceById(const std::string &id) const;
  virtual bool serialize(const std::string& fileName) const;
  virtual bool deserialize(const std::string& fileName);
  std::string newPresenceRecordId() const;
  void clear() { m_sessionPresences.clear(); }
  void insert(const SessionPresence& sessionPresence)
  {
    m_sessionPresences[sessionPresence.id()] = sessionPresence;
  }

  int size() const { return static_cast<int>(m_sessionPresences.size()); }

private:
  SessionPresenceMap m_sessionPresences;
};

#endif //SESSIONPRESENCEMANAGER_H